home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d883.lha / BBBBS / BBBBS59.lha / rexx / bbsSTATS.rexx < prev    next >
OS/2 REXX Batch file  |  1993-06-12  |  10KB  |  394 lines

  1. /*    $VER: bbsSTATS.rexx 5.9 (12.6.93)
  2. copyright 1993 Richard Lee Stockton * FREELY DISTRIBUTABLE
  3. */
  4.  
  5. NUMERIC DIGITS 14
  6. CR=''
  7. def=''
  8. pen3=''
  9. lineup=''
  10.  
  11. PARSE ARG name colorflag nonstop emailonline grand grand2 filesonline .
  12.  
  13. IF colorflag~=1 THEN
  14.   DO
  15.     def=''
  16.     pen3=''
  17.     lineup=''
  18.   END
  19. IF ADDRESS()='BAUD' THEN
  20.   DO
  21.     CR='0D'x
  22.     lineup='1B'x'M'
  23.   END
  24. IF filesonline='' THEN
  25.   DO
  26.     x=STRIP(GETCLIP('BBS_statsarg'))
  27.     CALL SETCLIP('BBS_statsarg')
  28.     IF x='' THEN
  29.       DO
  30.         filesonline='?'
  31.         IF emailonline='' THEN emailonline='?'
  32.       END
  33.     ELSE PARSE VAR x emailonline grand grand2 filesonline .
  34.   END
  35. IF grand='GRAND' | grand='' THEN grand='?'
  36.  
  37. figarg='s:CONFIG.BBS'
  38. IF ~EXISTS(figarg) THEN figarg='BBS:BBS_TEXT/CONFIG.BBS'
  39. x=OPEN(f,figarg,'R')
  40. IF x=0 THEN
  41.   DO
  42.     SAY 's:CONFIG.BBS and BBS:BBS/CONFIG.BBS are both missing!'
  43.     EXIT 21
  44.   END
  45. lynes.=''
  46. DO i=1 TO 33
  47.   lynes.i=READLN(f)
  48. END
  49. CALL CLOSE(f)
  50.  
  51. compos=POS('/*',lynes.1)
  52. IF compos>0 THEN lynes.1=LEFT(lynes.1,compos-1)
  53. bbsname = STRIP(lynes.1)
  54. sysop=WORD(lynes.2,1)
  55. bbsdevice=WORD(lynes.4,1)
  56. sysoplevel=WORD(lynes.5,1)
  57. bbspath=WORD(lynes.6,1)
  58. IF ~EXISTS(bbspath) THEN
  59.   DO
  60.     SAY bbspath 'does not exist!'
  61.     EXIT 22
  62.   END
  63. testchar=RIGHT(bbspath,1)
  64. IF testchar~='/' & testchar~=':' THEN bbspath=bbspath'/'
  65. SYSTEM_SPACE_LIMIT=WORD(lynes.12,1)
  66. IF grand2='GRAND2' | grand2='' THEN
  67.   DO
  68.     grand2=0
  69.     DO i=1 TO 99
  70.       grand2=grand2+countcheck(bbspath'Numbers/LastMessage'i 0)
  71.     END
  72.   END
  73.  
  74. x=OPEN(f,bbspath'Users/'name,'R')
  75. IF x=0 THEN
  76.   DO
  77.     CALL DELAY(150)
  78.     x=OPEN(f,bbspath'Users/'name,'R')
  79.     IF x=0 THEN
  80.       DO
  81.         SAY name 'user file is missing!'
  82.         EXIT 23
  83.       END
  84.   END
  85. data.=''
  86. DO i=1 TO 25
  87.   data.i=READLN(f)
  88. END
  89. CALL CLOSE(f)
  90. lpp=data.7%1
  91. level=data.20%1
  92. lastread.=0
  93.  
  94. IF nonstop='' THEN
  95.   DO
  96.     nonstop=1
  97.     CALL CLOSE(STDOUT)
  98.     CALL OPEN(STDOUT,bbspath'EmailFiles/'name'/Notices/STATS.BBS','W')
  99.   END
  100.  
  101. x=GETCLIP('BBS_'name'_22')
  102. IF x~='' THEN
  103.   DO
  104.     data.22=x
  105.     CALL SETCLIP('BBS_'name'_22')
  106.   END
  107.  
  108. SAY GETCLIP('BBS_copyright')||CR
  109. CALL SETCLIP('BBS_copyright')
  110. prevcaller=GETCLIP('BBS_prevcaller')
  111. IF prevcaller~='' THEN
  112.   DO
  113.     SAY 'The previous'pen3 bbsname def'user was:'CR
  114.     SAY ' 'prevcaller||CR
  115.     SAY '  logged off at:' GETCLIP('BBS_userlogoff')||CR
  116.     SAY pen3'Last disconnect:'def GETCLIP('BBS_disconnect')||CR
  117.   END
  118. SAY CR
  119. day1='01'
  120. IF readopen(bbspath'Numbers/FirstLogon') THEN
  121.   DO
  122.     line=READLN(f)
  123.     CALL CLOSE(f)
  124.     SAY 'The First Logon to'pen3 bbsname def'was' line'.'CR
  125.     PARSE VAR line .' 'day1'-'.
  126.   END
  127. IF day1<10 & LENGTH(day1)<2 THEN day1='0'day1
  128. SAY '     Your sysop is' pen3||sysop||def||CR
  129. SAY CR
  130. usagelist=SHOWDIR(bbspath'Usage','F')
  131. tempnum=FIND(usagelist,'USER.LOG')
  132. IF tempnum>0 THEN usagelist=DELWORD(usagelist,tempnum,1)
  133. usagelist=sortnumbers(usagelist)
  134. SAY pen3'             - Total BBS Usage -'def||CR
  135. DO i=1 TO WORDS(usagelist)
  136.   dateclip=STRIP(WORD(usagelist,i))
  137.   IF i=1 THEN day1=dateclip||day1
  138.   usageclip=countcheck(bbspath'Usage/'dateclip 0)
  139.   usageclp=usageclip%60 usageclip//60
  140.   mtime=30*23*60  /* we guess 1 hour a day for various maintenance */
  141.   IF dateclip=LEFT(DATE('S'),6) THEN mtime=RIGHT(DATE('S'),2)*23*60
  142.   dateclip=dateclip'01'
  143.   line=RIGHT(DATE('M',dateclip,'S'),10) WORD(DATE(,dateclip,'S'),3)':'
  144.   line=line RIGHT(WORD(usageclp,1),3) 'hours' RIGHT(WORD(usageclp,2),2)
  145.   line=line 'minutes  = ' RIGHT(((usageclip*100)/mtime)%1,2)'% usage.'
  146.   SAY line||CR
  147.   IF (i+12)//(lpp-3)=0 THEN
  148.     IF waiting2() THEN LEAVE i
  149. END
  150. cmin=countcheck(bbspath'Numbers/Minutes' 0)
  151. chr=cmin%60
  152. cmin=cmin//60
  153. hrz=chr
  154. daz=1
  155. IF hrz<1 THEN hrz=1
  156. IF day1>19900101 THEN
  157.   DO
  158.     daz=1+DATE('I')-DATE('I',day1,'S')
  159.     hrz=daz*24
  160.   END
  161. SAY CR
  162. SAY '     Total Connect Time Since First Logon [all users]:'CR
  163. SAY RIGHT(comma(chr),20) 'hours' RIGHT(cmin,2) 'minutes  = ' RIGHT(((chr*100)/hrz)%1,2)'% usage.'CR
  164. calls=countcheck(bbspath'Numbers/Calls' 0)
  165. IF calls<1 THEN calls=1
  166. SAY RIGHT(comma(calls),20) 'completed calls.    'TRUNC((calls/daz)+.05,1) 'calls per day.'CR
  167. SAY CR
  168. CALL waiting2()
  169. IF waitchar='Q' THEN RETURN
  170. CALL bbsspace(15)
  171. SAY CR
  172. IF extdevs~='' THEN CALL showxdevs()
  173. SAY RIGHT(comma(countcheck(bbspath'Numbers/Bytes.DownLoad' 0)),15) 'bytes  in' RIGHT(comma(countcheck(bbspath'Numbers/Files.DownLoad' 0)),7) 'files downloaded.'CR
  174. SAY CR
  175. SAY RIGHT(comma(countcheck(bbspath'Numbers/Bytes.UpLoad' 0)),15) 'bytes  in' RIGHT(comma(countcheck(bbspath'Numbers/LastFile' 0)),7) 'files uploaded.'CR
  176. IF emailonline<0 THEN CALL countmail()
  177. SAY RIGHT(comma(emailonline),15) 'online of' RIGHT(comma(countcheck(bbspath'Numbers/LastMail' 0)),7) 'private messages.'CR
  178. SAY RIGHT(comma(grand),15) 'online of' RIGHT(comma(grand2),7) 'public messages.'CR
  179. SAY RIGHT(comma(filesonline),15) 'online of' RIGHT(comma(countcheck(bbspath'Numbers/LastFile' 0)),7) 'public files.'CR
  180. userlist=SHOWDIR(bbspath'USERS','F')
  181. SAY RIGHT(comma(WORDS(userlist)),15) 'active of' RIGHT(comma(countcheck(bbspath'Numbers/Users' 0)),7) 'user applications.'CR
  182. SAY CR
  183. SAY 'Your access level is 'level'  -  minimum sysop level is' sysoplevel||CR
  184. SAY CR
  185. SAY '  You Have'CR
  186. totmail=WORD(data.17,2)
  187. IF ~DATATYPE(totmail,'W') THEN totmail=0
  188. totmsg=0
  189. DO ti=1 TO level
  190.   temp=WORD(data.23,ti)
  191.   IF DATATYPE(temp,'W') THEN totmsg=totmsg+WORD(data.23,ti)
  192. END
  193. SAY '   Written' RIGHT(comma(totmsg),14)'  public &' RIGHT(comma(totmail),8)'  private messages.'CR
  194. totfiles=WORD(data.14,1)
  195. IF ~DATATYPE(totfiles,'W') THEN totfiles=0
  196. totbytes=WORD(data.14,3)
  197. IF ~DATATYPE(totbytes,'W') THEN totbytes=0
  198. SAY '  Uploaded' RIGHT(comma(totbytes),14)'  bytes in' RIGHT(comma(totfiles),8)'  files.'CR
  199. totfiles=WORD(data.15,1)
  200. IF ~DATATYPE(totfiles,'W') THEN totfiles=0
  201. totbytes=WORD(data.15,3)
  202. IF ~DATATYPE(totbytes,'W') THEN totbytes=0
  203. SAY 'Downloaded' RIGHT(comma(totbytes),14)'  bytes in' RIGHT(comma(totfiles),8)'  files.'CR
  204. PARSE VAR data.19 dhour' hours 'dmin' minutes in 'calls .
  205. IF ~DATATYPE(dhour,'W') THEN dhour=0
  206. IF ~DATATYPE(dmin,'W') THEN dmin=0
  207. IF ~DATATYPE(calls,'W') THEN calls=0
  208. SAY '..and been on' bbsname dhour 'hours' dmin+TIME('E')%60 'minutes in' calls+1 'calls.'CR
  209. EXIT
  210.  
  211.  
  212. waiting2:
  213. IF nonstop=1 THEN RETURN 0
  214. waitchar=getinput(1 1 pen3'   Q=Quit   N=Non-Stop   RETURN=Continue  'def)
  215. IF waitchar='N' THEN
  216.   DO
  217.     nonstop=1
  218.     waitchar=''
  219.   END
  220. CALL cleanline(1)
  221. IF waitchar='Q' THEN RETURN 1
  222. RETURN 0
  223.  
  224.  
  225. cleanline:
  226. ARG lflag .
  227. IF colorflag~=1 & lflag=1 THEN RETURN
  228. cline=lineup||LEFT(' ',78)
  229. IF lflag=1 THEN cline=cline||lineup
  230. SAY cline||CR
  231. RETURN
  232.  
  233.  
  234. getinput:
  235. PARSE ARG upflag' 'oneflag' 'pline
  236. OPTIONS PROMPT pline
  237. PARSE PULL inarg
  238. inarg=STRIP(inarg)
  239. IF upflag THEN inarg=UPPER(inarg)
  240. IF oneflag THEN inarg=LEFT(inarg,1)
  241. RETURN inarg
  242.  
  243.  
  244. countcheck:
  245. PARSE ARG fname' 'cknum' '.
  246. IF ~EXISTS(fname) THEN
  247.   DO
  248.     IF cknum=0 THEN RETURN 0
  249.     IF ~writeopen(fname) THEN RETURN 0
  250.     CALL WRITELN(f,cknum)
  251.     CALL CLOSE(f)
  252.     RETURN cknum
  253.   END
  254. IF ~readopen(fname) THEN RETURN cknum
  255. retval=STRIP(READLN(f))
  256. CALL CLOSE(f)
  257. IF ~DATATYPE(retval,'W') THEN retval=0
  258. IF ~DATATYPE(cknum,'W') THEN cknum=0
  259. IF retval<cknum THEN
  260.   DO
  261.     IF writeopen(fname) THEN
  262.       DO
  263.         CALL WRITELN(f,cknum)
  264.         CALL CLOSE(f)
  265.         RETURN cknum
  266.       END
  267.   END
  268. RETURN retval
  269.  
  270.  
  271. readopen:
  272. PARSE ARG fname
  273. ok=OPEN(f,fname,'R')
  274. IF ok~=0 THEN RETURN 1
  275. SAY fname 'failed to open for reading!'CR
  276. RETURN 0
  277.  
  278.  
  279. writeopen:
  280. PARSE ARG fname
  281. CALL CLOSE(f)
  282. ok=OPEN(f,fname,'W')
  283. IF ok~=0 THEN RETURN 1
  284. SAY fname 'failed to open for writing!'CR
  285. RETURN 0
  286.  
  287.  
  288. comma:
  289. ARG num .
  290. dgt=LENGTH(num)
  291. numtext=''
  292. IF dgt>3 THEN numtext=','RIGHT(num,3)
  293. IF dgt>6 THEN numtext=','LEFT(RIGHT(num,6),3)||numtext
  294. IF dgt>9 THEN numtext=','LEFT(RIGHT(num,9),3)||numtext
  295. IF dgt>12 THEN
  296.   DO
  297.     numtext=','LEFT(RIGHT(num,12),3)||numtext
  298.     numtext=LEFT(num,dgt-12)||numtext
  299.   END
  300. ELSE IF dgt>9 THEN numtext=LEFT(num,dgt-9)||numtext
  301. ELSE IF dgt>6 THEN numtext=LEFT(num,dgt-6)||numtext
  302. ELSE IF dgt>3 THEN numtext=LEFT(num,dgt-3)||numtext
  303. ELSE numtext=num
  304. RETURN numtext
  305.  
  306.  
  307. sortnumbers:
  308. PARSE ARG slist
  309. IF STRIP(slist)='' THEN RETURN ''
  310. sorted.=''
  311. oldest=999999
  312. newest=0
  313. newlist=''
  314. DO si=1 TO WORDS(slist)
  315.   testword=WORD(slist,si)
  316.   IF ~DATATYPE(testword,'W') THEN
  317.     DO
  318.       testpos=LASTPOS('.',testword)
  319.       IF testpos>0 THEN tempnum=SUBSTR(testword,testpos+1)
  320.       ELSE
  321.         DO
  322.           newlist=testword newlist
  323.           ITERATE si
  324.         END
  325.     END
  326.   ELSE tempnum=testword/1
  327.   IF sorted.tempnum='' THEN
  328.     DO
  329.       sorted.tempnum=testword
  330.       sorted.tempnum.0=1
  331.       IF DATATYPE(tempnum,'W') THEN
  332.         DO
  333.           IF tempnum>newest THEN newest=tempnum
  334.           IF tempnum<oldest THEN oldest=tempnum
  335.         END
  336.     END
  337.   ELSE newlist=newlist testword
  338. END
  339. IF oldest~=999999 & newest~=0 THEN
  340.   DO si=oldest TO newest
  341.     IF sorted.si.0=1 THEN newlist=newlist sorted.si
  342.   END
  343. DROP sorted. oldest newest
  344. RETURN STRIP(newlist)
  345.  
  346.  
  347. bbsspace:
  348. ARG tabspace .
  349. ADDRESS COMMAND 'C:info >ram:infout' bbsdevice
  350. ok=OPEN(f,'ram:infout','R')
  351. IF ok=0 THEN RETURN 20
  352. line=READLN(f)
  353. line=READLN(f)
  354. line=READLN(f)
  355. line=READLN(f)
  356. CALL CLOSE(f)
  357. IF tabspace<14 THEN SAY CR
  358. bbsk=WORD(line,4)
  359. IF ~DATATYPE(bbsk,'N') THEN
  360.   DO
  361.     line=bbsdevice 'is not an info compatible device!'
  362.     SAY pen3||line||def||CR
  363.     bbsk=0
  364.     RETURN
  365.   END
  366. bbsk=bbsk*512-SYSTEM_SPACE_LIMIT
  367. IF bbsk<1 THEN bbsk=0
  368. SAY RIGHT(comma(bbsk),tabspace) 'bytes available for uploads.'CR
  369. RETURN
  370.  
  371.  
  372. showxdevs: PROCEDURE EXPOSE bbspath pen3 def CR 
  373. CALL FileList(bbspath'Numbers/Files.X.*',xfiles,'F','N')
  374. IF xfiles.0>1 THEN CALL QSORT(1,xfiles.0,xfiles)
  375. DO i=1 TO xfiles.0
  376.   ii=LASTPOS('FILES.X.',UPPER(xfiles.i))+8
  377.   temp=SUBSTR(xfiles.i,ii)
  378.   SAY RIGHT(comma(countcheck(bbspath'Numbers/Bytes.X.'temp 0)),15) 'bytes  in' RIGHT(comma(countcheck(bbspath'Numbers/Files.X.'temp 0)),7)' files downloaded from' pen3||temp||def||CR
  379. END
  380. SAY LEFT('-',74,'-')||CR
  381. RETURN
  382.  
  383.  
  384. countmail:
  385. SAY '   Counting online email...'lineup||CR
  386. emailonline=0
  387. DO ti=1 TO WORDS(userlist)
  388.   emailonline=emailonline+WORDS(SHOWDIR(bbspath'Email/'WORD(userlist,ti)))
  389. END
  390. RETURN
  391.  
  392.  
  393. /* bbsSTATS.rexx */
  394.